package com.pignest.framework.dao;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import org.hibernate.type.Type;

public interface Dao {

	public <T> List<T> listAll(Class<T> clazz);

	public <T> T get(Class<T> clazz, Serializable id);
	
	public <T> T get(Class<T> clazz, String key, Object value);

	public void delete(Object o);

	public <T> void delete(Class<T> clazz, Serializable id);
	
	public void insert(Object o);
	
	public void update(Object o);

	public void insertOrUpdate(Object o);
	
	public void saveAll(Collection<?> entities);

	public <T> List<T> find(String hql);
	
	public String defaultOrderBy();
	
	public <T> int count(Class<T> clazz, String search, Object[] values, Type[] types);
	
	public <T> List<T> query(Class<T> clazz, String search, int pageSize, int pageIndex, Object[] values, Type[] types);

	public int update(final String hql);
	
	public int updateByHQL(String hql, String[] paramNames, Object[] paramValues);
	
	
/*	// 使用原生SQL查询 
	public List findByNativeSQL(final String sql, final String[] columnAliases);

	// 使用原生SQL查询 
	public List findByNativeSQL(final String sql, final String[] columnAliases, final int firstResult,
			final int maxResults);
	
	public <T> List<T> findByNamedQuery(String queryName);

	public <T> List<T> findByNamedQuery(String queryName, Object[] values);
	
	public <T> List<T> findByNamedQueryNoCache(String queryName, Object[] values);

	public List findByHQLUseIterator(final String sHql, final String[] paramNames, final Object[] paramValues,
			final int firstResult, final int maxResults);

	public List findByHQLUseList(final String sHql, final String[] paramNames, final Object[] paramValues,
			final int firstResult, final int maxResults);


	public List findByHQLUseListNoCache(final String sHql, final String[] paramNames, final Object[] paramValues,
			final int firstResult, final int maxResults);


	public List findByCriteria(DetachedCriteria detachedCriteria);

	public List findByCriteria(DetachedCriteria detachedCriteria, final int firstResult, final int maxResults)
			throws DataAccessException;

	public HibernateTemplate getHibernateTemplate();

	public int updateByHQL(final String hql, final String[] paramNames, final Object[] paramValues);

	public void flush();
*/
	/**
     * 使用hql 语句进行分页操作  
     * @param hql
     * @param start
     * @param length
     * @return List
     */ 
    public <T>List<T> getListForPage(final String hql, final int start,
      final int length);
}
